<--- %%NOBANNER%% --> libcode.sas
 BackForward
/* Generate SAS files for All the Tables in a library */
%macro libcode (saslib, codefile, codetype);
%if (%index(%sysfunc(pathname(saslib)), %quote(\)) or 
     %index(%sysfunc(pathname(saslib)), %quote(/))) %then %do;
   proc contents data=&saslib.._all_ out = libmem(keep= memname varnum) position noprint; run;
%end;
%else %if (%quote(%sysfunc(pathname(saslib))) ne) %then %do;
   proc sql;
      create table libmem as
      select distinct TABLE_NAME as memname
      from dvdbms.all_tables;
   data libmem;
      set libmem;
      format varnum best12.;
      dsid=open("%trim(%left(&saslib))."||memname);
      if dsid then do;
         varnum=attrn(dsid,'NVARS');
         rc=close(dsid);
      end;
      else delete;
      drop dsid rc;
   run; quit;
%end;
proc sort data=libmem nodupkey; by memname; where memname not in('CORRECT','DIRLIST','ENROLL','INVEST',
   'JOURNAL','PAGES','RSLVLOG','STATLOG','TRACK','TRANJRN1','TRANJRN2','_TRACK_');
run;
data _null_;
   set libmem end=last;
   call symput('d'||left(_N_), memname);
   if last then call symput('numrec', _N_);
run;
%do i = 1 %to &numrec;
   %codegen(%trim(%left(&saslib)).%trim(%left(&&d&i)), &codefile, &codetype);
%end;
%mend libcode;